<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="text" id="input" />
    <p id="p"></p>
    <script>
      let input = document.getElementById('input')
      let p = document.getElementById('p')
      let obj = {}
      Object.defineProperty(obj, 'name', {
        set(val) {
          input.val = val
          p.innerHTML = val
        },
        get() {
          return val
        },
      })
      input.addEventListener('input', function (e) {
        obj.name = e.target.value
      })
    </script>
  </body>
</html>
